<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>金字塔</title>
</head>
<style>
    body{
        font-family: cursive,serif;
    }
</style>
<body>
<script>
    var p = prompt("请输入金字塔的层数");
    for(var i = 1;i<=p;i++){
        var b = p - i;
        for(var j = 0;j<b;j++){
            document.write("&nbsp");
        }
        var a = i*2-1;
        for(var k=0;k<a;k++){
            document.write("*");
        }
        document.write("<br>");
    }
</script>
</body>
</html>